package com.llkj.common.util;

import android.content.Intent;
import android.os.Message;
import android.support.design.widget.Snackbar;

import com.llkj.common.base.app.AppManager;

import static com.llkj.common.base.app.AppManager.APP_EXIT;
import static com.llkj.common.base.app.AppManager.KILL_ALL;
import static com.llkj.common.base.app.AppManager.SHOW_SNACKBAR;
import static com.llkj.common.base.app.AppManager.START_ACTIVITY;

/**
 * author: zhu.px
 * e-mail: 1271901673@qq.com
 * time  : 2018/4/18
 * desc  :
 */
public class CommonUtil {
    /**
     * 使用 {@link Snackbar} 长时间显示文本消息
     *
     * @param text
     */
    public static void snackbarTextWithLong(String text) {
        Message message = new Message();
        message.what = SHOW_SNACKBAR;
        message.obj = text;
        message.arg1 = 1;
        AppManager.post(message);
    }

    /**
     * 跳转界面 1 ,通过 {@link AppManager#startActivity(Class)}
     *
     * @param activityClass
     */
    public static void startActivity(Class activityClass) {
        Message message = new Message();
        message.what = START_ACTIVITY;
        message.obj = activityClass;
        AppManager.post(message);
    }

    /**
     * 跳转界面 2 ,通过 {@link AppManager#startActivity(Intent)}
     *
     * @param
     */
    public static void startActivity(Intent content) {
        Message message = new Message();
        message.what = START_ACTIVITY;
        message.obj = content;
        AppManager.post(message);
    }

    /**
     * 远程遥控 {@link AppManager#killAll()}
     */
    public static void killAll() {
        Message message = new Message();
        message.what = KILL_ALL;
        AppManager.post(message);
    }

    /**
     * 远程遥控 {@link AppManager#appExit()}
     */
    public static void exitApp() {
        Message message = new Message();
        message.what = APP_EXIT;
        AppManager.post(message);
    }
}
